package com.mccken.practice.test;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-03-10 00:27
 **/
public class Demo {

	static class UserTemp {

	}

	private static UserTemp userTemp;

	// ab并行，任意完成再c
	public static void main(String[] args) {
		Demo demo = new Demo();
		for (int i = 0; i < 10; i++) {
			new Thread(() -> {
				System.out.println(demo.getUserTemp());
			}).start();
		}
	}

	public UserTemp getUserTemp() {
		if (userTemp == null) {
			synchronized (UserTemp.class) {
				if (userTemp == null) {
					userTemp = new UserTemp();
				}
			}
		}

		return userTemp;
	}
	
	
	
}
